home *** CD-ROM | disk | FTP | other *** search
/ Windows 6-Pak - Disc 4 / Windows 6-Pak (InfoMagic) (Disc 4) (1999).ISO / Text-Chat-Scripts / pp-320m.exe / addons / uemail2.mrc < prev    next >
Text File  |  1998-06-20  |  30KB  |  728 lines

  1. ; -----------------------------------------------------
  2. ; Peace and Protection (by misspai)
  3. ; -----------------------------------------------------
  4. ; ADDON: E-Mail (2 of 2)
  5. ; -----------------------------------------------------
  6. alias eends if (%email.cret) return $1- $+ $lf | return $1- $+ $cr $+ $lf
  7. alias _mailcfg if ($2 == $null) set %.read $readini -n $_ppdir $+ email.ini settings $_iniprep($1) | else set %.read $readini -n $_ppdir $+ email.ini $1 $_iniprep($2-) | return $_readprep(%.read)
  8. alias _writemailc if ($3 == $null) _remmailc $1- | else writeini $_ppdir $+ email.ini $1 $2 $3-
  9. alias _edosend {
  10.   _timer924on
  11.   _escancel !
  12.   unset %_ems.lastwin
  13.   if (%email.smtp == $null) _error SMTP server not defined- See E-Mail setup
  14.   if (%email.email == $null) _error E-Mail address not defined- See E-Mail setup
  15.   if ($line($1,$line($1,0)) != $chr(160)) aline $1 $chr(160)
  16.   set %_ems.win $1
  17.   set %_ems.to $gettok($line($1,5),2-,32)
  18.   if (< isin %_ems.to) set %.tutu $remove($gettok(%_ems.to,2,60),>)
  19.   elseif ($chr(40) isin %_ems.to) set %.tutu $gettok(%_ems.to,1,40)
  20.   else set %.tutu %_ems.to
  21.   if (@ !isin %.tutu) { unset %_ems.win %_ems.to | _error You must give a legitimate e-mail address to send to! }
  22.   _dynpop.rot email 9 %_ems.to
  23.   set %_ems.hideto $true
  24.   set %_ems.targets $_numtok(44,%_ems.to)
  25.   set %.pre %_ [ $+ [ $1 ] ] | dec %.pre 2
  26.   set %.targ 2
  27.   :loop
  28.   set %.tok $strip($remove($remove($gettok($line($1,%.pre),1,32),CC),Blind))
  29.   if ((%.tok == :) || ($remove(%.tok,:) isnum)) {
  30.     if (blind !isin $gettok($line($1,%.pre),1,32)) set %_ems.hideto $false
  31.     set %_ems.to [ $+ [ %.targ ] ] $gettok($line($1,%.pre),2-,32)
  32.     inc %_ems.targets $_numtok(44,$gettok($line($1,%.pre),2-,32))
  33.     inc %.targ
  34.   }
  35.   if ($_vd(.pre) > 3) goto loop
  36.   if (%_ems.targets < 2) set %_ems.hideto $false
  37.   sline $1 1
  38.   _progress.1 Sending e-mail...
  39.   set %.ini $_mircdir $+ mirc.ini
  40.   set %_ems.oldident $readini %.ini ident userid
  41.   set %_ems.oldactive $readini %.ini ident active
  42.   .identd on $gettok(%email.email,1,64)
  43.   set %_ems.todo $line(%_ems.win,0)
  44.   set %_ems.progr $calc(%_ems.todo + %_ems.targets + 3)
  45.   set %.lof $lines(%email.sig)
  46.   if (%.lof > 0) inc %_ems.progr %.lof
  47.   set %_ems.progc 0 | set %_ems.progt 2
  48.   .enable #_esend
  49.   _esprog Resolving DNS of SMTP server...
  50.   _esprog Logging in to SMTP server...
  51.   sockopen ULTE-SEND %email.smtp 25
  52. }
  53. alias _escancel {
  54.   window -c @Progress
  55.   .disable #_esenddns #_esend
  56.   unset %_ems.stage %_ems.win %_ems.to* %_ems.lastwin %_ems.prog? %_ems.targets %_ems.hideto
  57.   _qlogc $1
  58.   if (%_ems.oldident != $null) {
  59.     .identd on %_ems.oldident
  60.     if (%_ems.oldactive != yes) .identd off
  61.     unset %_ems.oldident %_ems.oldactive
  62.   }
  63. }
  64. #_esend off
  65. on 1:sockopen:ULTE-SEND:{
  66.   if ($sockerr > 0) _error Error connecting to mail server
  67.   else _esprog Handshaking with server...
  68. }
  69. on 1:sockclose:ULTE-SEND:_escancel | _error Mail server disconnected unexpectedly
  70. on 1:sockread:ULTE-SEND:{
  71.   :loop
  72.   sockread %.sockdata
  73.   if ($sockbr == 0) return
  74.   _esenddo1 %.sockdata
  75.   goto loop
  76. }
  77. alias -l _esenddo1 {
  78.   if ($1 == 220) { sockwrite ULTE-SEND HELO $eends($gettok(%email.email,2,64)) | set %_ems.stage 1 }
  79.   elseif (25? iswm $1) {
  80.     if (%_ems.stage == 1) sockwrite ULTE-SEND MAIL FROM:< $+ %email.email $+ $eends(>)
  81.     elseif (%_ems.stage == 2) {
  82.       :next
  83.       _esprog Sending receipients list...
  84.       set %.gorg $gettok(%_ems.to,1,44)
  85.       set %_ems.to $gettok(%_ems.to,2-,44)
  86.       if (< isin %.gorg) set %.gorg $remove($gettok(%.gorg,2,60),>)
  87.       set %.gorg $gettok(%.gorg,1,32)
  88.       if (@ isin %.gorg) sockwrite ULTE-SEND RCPT TO:< $+ %.gorg $+ $eends(>)
  89.       if (%_ems.to == $null) {
  90.         set %_ems.to %_ems.to [ $+ [ %_ems.progt ] ]
  91.         set %_ems.to [ $+ [ %_ems.progt ] ]
  92.         inc %_ems.progt
  93.       }
  94.       if (%_ems.to != $null) {
  95.         if (%email.fastsend isin onyesenabled$true) goto next
  96.         halt
  97.       }
  98.     }
  99.     elseif (%_ems.stage == 3) sockwrite ULTE-SEND $eends(DATA)
  100.     elseif (%_ems.stage == 0) sockwrite ULTE-SEND $eends(QUIT)
  101.     inc %_ems.stage
  102.   }
  103.   elseif ($left($1,1) isin 45) { _escancel | _error Error from server when sending mail- $2- }
  104.   elseif ($1 == 354) {
  105.     _esprog Sending mail header...
  106.     if (%email.ffrom == $null) sockwrite ULTE-SEND From: $eends(%email.email)
  107.     else sockwrite ULTE-SEND From: %email.ffrom < $+ %email.email $+ $eends(>)
  108.     set %.+did.from: $true
  109.     if (%_ems.hideto) set %.+did.to: $true
  110.     set %.num 5
  111.     :loop1
  112.     set %.line $line(%_ems.win,%.num)
  113.     _esprog2
  114.     if (%.line != $chr(160)) {
  115.       set %.field $strip($gettok(%.line,1,32))
  116.       set %.data $gettok(%.line,2-,32)
  117.       if ((%.+did. [ $+ [ %.field ] ] != $true) && ( !isin %.data)) {
  118.         set %.+did. [ $+ [ %.field ] ] $true
  119.         if (BlindCC !isin %.field) sockwrite -t ULTE-SEND %.field $eends(%.data)
  120.       }
  121.       inc %.num
  122.       goto loop1
  123.     }
  124.     inc %.num
  125.     if ((%.+did.reply-to: != $true) && (%email.replyto != $null) && (%email.replyto != %email.email)) sockwrite ULTE-SEND Reply-to: $eends(%email.replyto)
  126.     if ((%.+did.organization: != $true) && (%email.org != $null)) sockwrite ULTE-SEND Organization: $eends(%email.org)
  127.     set %.line X-Mailer: P&P %pp.ver for mirc $version $+ $lf
  128.     :loop2
  129.     _esprog2
  130.     set %.next $_f2s($line(%_ems.win,%.num))
  131.     if (%.next == $null) {
  132.       set %.line %.line $+ $lf
  133.       if ($_vi(.num) < %_ems.todo) goto loop2
  134.       sockwrite -t ULTE-SEND $eends(%.line)
  135.       goto nexts
  136.     }
  137.     sockwrite -t ULTE-SEND $eends(%.line)
  138.     set %.line %.next
  139.     if ($left(%.line,1) == .) set %.line . $+ %.line
  140.     inc %.num
  141.     goto loop2
  142.     :nexts
  143.     if (%email.sig != $null) {
  144.       set %.max $lines(%email.sig)
  145.       if (%.max > 0) {
  146.         set %.num 1
  147.         :loop
  148.         _esprog Sending signature...
  149.         set %.line $read -nl [ $+ [ %.num ] ] %email.sig
  150.         if ($left(%.line,1) == .) sockwrite ULTE-SEND . $+ $eends(%.line)
  151.         elseif (%.line != $null) sockwrite -t ULTE-SEND $eends(%.line)
  152.         if ($_vi(.num) <= %.max) goto loop
  153.       }
  154.     }
  155.     _esprog Logging off...
  156.     sockwrite ULTE-SEND $eends(.)
  157.     set %_ems.stage 0
  158.   }
  159.   elseif ($1 == 221) {
  160.     _progress.2 100 Mail sent! (press F4 to close this and e-mail window)
  161.     .disable #_esend
  162.     set %_ems.lastwin %_ems.win
  163.     unset %_ems.stage %_ems.win %_ems.to* %_ems.prog? %_ems.targets
  164.     if (%_ems.oldident != $null) {
  165.       .identd on %_ems.oldident
  166.       if (%_ems.oldactive != yes) .identd off
  167.       unset %_ems.oldident %_ems.oldactive
  168.     }
  169.     sockclose ULTE-SEND
  170.     halt
  171.   }
  172. }
  173. alias _esprog inc %_ems.progc | set %.perc $int($calc(%_ems.progc * 100 / %_ems.progr)) | _progress.2 %.perc $1-
  174. alias _esprog2 inc %_ems.progc | if ($_vi(.emsp) < 5) return | unset %.emsp | set %.perc $int($calc(%_ems.progc * 100 / %_ems.progr)) | _progress.2 %.perc Sending message...
  175. #_esend end
  176. alias ebook {
  177.   window -c @Address
  178.   window -l @Address $_winpos(21%,14%,21%,21%) @Address %font.basic
  179.   set %.num 1
  180.   :loop
  181.   set %.addr $_mailcfg(%email.book,%.num)
  182.   if (%.addr != $null) { aline @Address %.addr | inc %.num | goto loop }
  183.   aline @Address %=
  184.   aline @Address Add new entry...
  185.   if ($1 == $null) { aline @Address (double-click to modify an entry) | unset %_addr.pop }
  186.   else { aline @Address (double-click to select an entry) | set %_addr.pop Select entry }
  187.   unset %_addr.pop2
  188.   if ($2 != $null) set %_addr.pop2 Select all entries
  189.   aline @Address (right-click to delete an entry)
  190.   aline @Address %=
  191.   aline @Address Current book- %col.target $+ $remove(%email.book,Book) $+  - %col.dark $+ $_mailcfg(%email.book,Name) $+  (double-click for books)
  192.   titlebar @Address book - $_mailcfg(%email.book,Name) ( $+ $remove(%email.book,Book) $+ )
  193.   aline @Address Create new book...
  194.   set %_addr.target $1
  195.   set %_addr.max %.num
  196.   set %_addr.cc $2
  197. }
  198. menu @Address {
  199.   dclick /if ($1 < %_addr.max) { if (%_addr.target == $null) _ab.mod $1 | else _ab.sel $1 } | %.tmp = 1 + %_addr.max | if ($1 == %.tmp) _ab.add | inc %.tmp 4 | if ($1 == %.tmp) _ebsel _ab.book sel Select a book | inc %.tmp | if ($1 == %.tmp) _abs.new
  200.   %_addr.pop:{
  201.     :loop
  202.     set %.num $sline(@Address,1).ln
  203.     if ((%.num < 1) || (%.num >= %_addr.max)) halt
  204.     _ab.sel %.num
  205.     sline -r @Address $sline(@Address,1).ln
  206.     goto loop
  207.   }
  208.   %_addr.pop2:{
  209.     set %.num 1
  210.     :loop
  211.     if (%.num >= %_addr.max) halt
  212.     _ab.sel %.num
  213.     inc %.num | goto loop
  214.   }
  215.   -
  216.   Delete entry
  217.   .Yes I'm sure:_ab.del
  218.   Modify entry...:set %.num $sline(@Address,1).ln | if ((%.num > 0) && (%.num < %_addr.max)) _ab.mod %.num
  219.   New entry...:_ab.add
  220.   -
  221.   Change book...:_ebsel _ab.book sel Select a book
  222.   New book...:_abs.new
  223.   Copy to another book...:_ebsel _ab.copy sel Book to copy to?
  224.   -
  225.   Copy to clipboard:clipboard $sline(@Address,1)
  226.   Import file...:_timer924off | set %.file $dir="File to grab e-mail addresses from?" [ [ $_mircdir ] $+ ] *.txt | _timer924on | if ((* isin %.file) || (%.file == $null)) halt | _ab.import %.file
  227.   Reduce to bare e-mails...:_askyn _ab.bare Remove all names for addresses, leaving only e-mail addresses?
  228.   -
  229.   Close:window -c @Address
  230. }
  231. alias eaddr ebook $1-
  232. alias _ebsel {
  233.   window -c @AddressBook
  234.   window -l @AddressBook $_winpos(21%,14%,22%,20%) @AddressBook %font.basic
  235.   titlebar @AddressBook selection - $3-
  236.   set %.num $_mailcfg(Books)
  237.   :loop
  238.   set %.ini Book $+ %.num
  239.   set %.addr $_mailcfg(%.ini,Name)
  240.   iline @AddressBook 1 Book %col.target $+ %.num $+  - %col.dark $+ %.addr
  241.   if ($_vd(.num) > 0) goto loop
  242.   aline @AddressBook %=
  243.   aline @AddressBook Create new book...
  244.   aline @AddressBook (double-click to select a book)
  245.   aline @AddressBook (right-click to delete or rename a book)
  246.   set %_abselcmd $1 $2
  247. }
  248. menu @AddressBook {
  249.   dclick /set %.tmp $_mailcfg(Books) | if ($1 <= %.tmp) _abs.sel $1 | if ($1 == $calc(%.tmp + 2)) _abs.new
  250.   Select book:set %.ln $sline(@AddressBook,1).ln | if ((%.ln <= $_mailcfg(Books)) && (%.ln > 0)) _abs.sel %.ln
  251.   -
  252.   Delete book
  253.   .Yes I'm sure:set %.ln $sline(@AddressBook,1).ln | if ((%.ln <= $_mailcfg(Books)) && (%.ln > 0)) _abs.del %.ln
  254.   Rename book...:set %.ln $sline(@AddressBook,1).ln | if ((%.ln <= $_mailcfg(Books)) && (%.ln > 0)) _abs.ren %.ln
  255.   New book...:_abs.new
  256.   -
  257.   Close:window -c @AddressBook
  258. }
  259. alias _abs.sel window -c @AddressBook | %_abselcmd $1
  260. alias _abs.del {
  261.   if ($_mailcfg(Books) <= 1) _error You must have at least one address book.
  262.   set %.tmp Book $+ $1 | _remmailc %.tmp
  263.   if ($1 < $_mailcfg(Books)) {
  264.     set %.tmp2 Book $+ $_mailcfg(Books) | _writemailc %.tmp Name $_mailcfg(%.tmp2,Name)
  265.     set %.num 1
  266.     :loop
  267.     set %.addr $_mailcfg(%.tmp2,%.num)
  268.     if (%.addr != $null) {
  269.       _writemailc %.tmp %.num %.addr
  270.       inc %.num | goto loop
  271.     }
  272.     _remmailc %.tmp2
  273.   }
  274.   else { set %.tmp2 %.tmp | set %.tmp Book1 }
  275.   _writemailc Settings Books $_j($_mailcfg(Books))
  276.   if ((%email.book == %.tmp) || (%email.book == %.tmp2)) {
  277.     set %email.book %.tmp
  278.     if ($_isopen(@Address)) window -c @Address
  279.   }
  280.   if ($_isopen(@AddressBook)) _ebsel %_abselcmd $gettok($window(@AddressBook).titlebar,3-,32)
  281. }
  282. alias _abs.ren set %.tmp Book $+ $1 | set %_arhelp _abs.ren2 $1 | _pentry _arhelp $+ $_s2p($_mailcfg(%.tmp,Name)) New name for address book $1?
  283. alias _abs.ren2 {
  284.   set %.tmp Book $+ $1 | _writemailc %.tmp Name $2-
  285.   if ((%email.book == %.tmp) && ($_isopen(@Address))) {
  286.     rline @Address $calc(%_addr.max + 5) Current book- %col.target $+ $1 - %col.dark $+ $2- (double-click for books)
  287.     titlebar @Address book - $2- ( $+ $1)
  288.   }
  289.   if ($_isopen(@AddressBook)) rline @AddressBook $1 Book %col.target $+ $1 - %col.dark $+ $2-
  290. }
  291. alias _abs.new _askr _abs.new2 Name for new address book?
  292. alias _abs.new2 {
  293.   set %.tmp $_mailcfg(Books) | inc %.tmp | _writemailc Settings Books %.tmp
  294.   set %.tmp2 Book $+ %.tmp | _writemailc %.tmp2 Name $1-
  295.   if ($_isopen(@AddressBook)) iline @AddressBook %.tmp Book %col.target $+ %.tmp $+  - %col.dark $+ $1-
  296.   elseif ($_isopen(@Address)) _ab.book sel %.tmp
  297. }
  298. alias _ab.book set %email.book Book $+ $2 | window -c @Address | ebook %_addr.target %_addr.cc
  299. alias _ab.copy {
  300.   set %.tmp Book $+ $2
  301.   set %.max 1
  302.   :loop1
  303.   if ($_mailcfg(%.tmp,%.max) != $null) { inc %.max | goto loop1 }
  304.   set %.num 1
  305.   :loop2
  306.   if ($sline(@Address,%.num).ln >= %_addr.max) return
  307.   set %.addr $sline(@Address,%.num)
  308.   if (%.addr != $null) { _writemailc %.tmp %.max %.addr | inc %.max | inc %.num | goto loop2 }
  309. }
  310. alias _ab.add _askr _ab.add2 E-Mail address of new entry?
  311. alias _ab.add2 set %_arhelp _ab.add3 $1 | _pentry _arhelp Name or nickname for new entry?2
  312. alias _ab.add3 {
  313.   if ($2 == $null) set %.new $1
  314.   else set %.new $2- < $+ $1>
  315.   set %.scan 1
  316.   if (%_addr.max > 1) {
  317.     :scan
  318.     set %.olda $remove($_rtok(1,60,$line(@Address,%.scan)),>)
  319.     if (%.olda == %.new) return $true
  320.     if ($_vi(.scan) < %_addr.max) goto scan
  321.   }
  322.   iline @Address %_addr.max %.new
  323.   _writemailc %email.book %_addr.max %.new
  324.   inc %_addr.max
  325.   return $false
  326. }
  327. alias _ab.import {
  328.   if ($1 != !) { window -c @Importing | window -n @Importing | loadbuf @Importing $1- }
  329.   set %.max $line(@Importing,0)
  330.   set %.cur 1 | set %.found 0 | unset %.dupe
  331.   _progress.1 Scanning file and importing e-mail addresses...
  332.   :loop1
  333.   set %.line $line(@Importing,%.cur)
  334.   if ($_vd(.pupd) < 0) {
  335.     set %.pupd 5
  336.     set %.perc $int($calc(%.cur * 100 / %.max))
  337.     _progress.2 %.perc %.perc $+ % complete... ( $+ %.found found)
  338.   }
  339.   if (@ isin %.line) {
  340.     :loop2
  341.     set %.pos $pos(%.line,@)
  342.     set %.from %.pos
  343.     :loop3
  344.     dec %.from
  345.     set %.bit $mid(%.line,%.from,1)
  346.     if ((%.bit isletter) || (%.bit isnum) || (%.bit isin .-_)) goto loop3
  347.     inc %.from
  348.     :loop4
  349.     inc %.pos
  350.     set %.bit $mid(%.line,%.pos,1)
  351.     if ((%.bit isletter) || (%.bit isnum) || (%.bit isin .-_)) goto loop4
  352.     %.len = %.pos - %.from
  353.     set %.email $mid(%.line,%.from,%.len)
  354.     if (($gettok(%.email,1,64) != $null) && (. isin $gettok(%.email,2,64))) { inc %.found | _ab.add3 %.email | if ($result) inc %.dupe }
  355.     set %.line $_rchop($_j(%.pos),%.line)
  356.     if (@ isin %.line) goto loop2
  357.   }
  358.   if ($_vi(.cur) <= %.max) goto loop1
  359.   if (%.dupe == $null) _progress.2 100 Import complete! %.found $_plural2(address,addresses,%.found) imported.
  360.   else _progress.2 100 Import complete! %.found found, %.dupe $_plural(duplicate,%.dupe) $+ , $calc(%.found - %.dupe) imported.
  361.   window -c @Importing
  362. }
  363. alias _ab.bare {
  364.   set %.num $_j(%_addr.max)
  365.   if (%.num > 0) {
  366.     :loop1
  367.     set %.line $line(@Address,%.num)
  368.     if (< isin %.line) rline @Address %.num $remove($gettok(%.line,2-,60),>)
  369.     if ($_vd(.num) > 0) goto loop1
  370.     set %.name $_mailcfg(%email.book,Name)
  371.     _remmailc %email.book
  372.     _writemailc %email.book Name %.name
  373.     set %.num 1
  374.     :loop2
  375.     _writemailc %email.book %.num $line(@Address,%.num)
  376.     if ($_vi(.num) < %_addr.max) goto loop2
  377.   }
  378. }
  379. alias _ab.del {
  380.   :loop1
  381.   set %.num $sline(@Address,1).ln
  382.   if ((%.num > 0) && (%.num < %_addr.max)) { dline @Address %.num | dec %_addr.max | goto loop1 }
  383.   set %.name $_mailcfg(%email.book,Name)
  384.   _remmailc %email.book
  385.   _writemailc %email.book Name %.name
  386.   if (%_addr.max > 1) {
  387.     set %.num 1
  388.     :loop2
  389.     _writemailc %email.book %.num $line(@Address,%.num)
  390.     if ($_vi(.num) < %_addr.max) goto loop2
  391.   }
  392. }
  393. alias _ab.mod {
  394.   set %.cur $line(@Address,$1)
  395.   if (< isin %.cur) { set %.who $gettok(%.cur,1,60) | set %.email $remove($gettok(%.cur,2,60),>) }
  396.   else { unset %.who | set %.email %.cur }
  397.   set %_arhelp _ab.mod2 $1
  398.   _pentry _arhelp $+  $+ $_s2p(%.email) New e-mail address for entry?
  399. }
  400. alias _ab.mod2 {
  401.   set %_arhelp _ab.mod3 $1 $2
  402.   if (%.who == $null) _pentry _arhelp Name or nickname for entry?2
  403.   else _pentry _arhelp $+  $+ $_s2p(%.who) New name or nickname for entry?
  404. }
  405. alias _ab.mod3 {
  406.   if ($3 == $null) set %.new $2
  407.   else set %.new $3- < $+ $2>
  408.   rline @Address $1 %.new
  409.   _writemailc %email.book $1 %.new
  410. }
  411. alias _ab.sel {
  412.   set %.addr $line(@Address,$1)
  413.   if ($_not($_isopen(%_addr.target))) halt
  414.   if (cc isin %_addr.cc) _ce.cc %_addr.target %_addr.cc %.addr
  415.   else {
  416.     window -c @Address
  417.     rline %col.base %_addr.target 5 To: %.addr
  418.     titlebar %_addr.target e-mail to $_s2f($gettok(%.addr,1,60)) - $gettok($window(%_addr.target).titlebar,5-,32)
  419.     halt
  420.   }
  421. }
  422. alias eacc {
  423.   set %-+eacs.halt $true
  424.   _esaveacc %email.accnum
  425.   if ($1 == $null) { disp Current e-mail account - %col.target $+ %email.accnum $+  - %email.account | halt }
  426.   if (v isin $1) {
  427.     open @Info /eacc E-Mail account info
  428.     dispr @Info E-Mail accounts-
  429.     set %.num 1
  430.     :loop
  431.     set %.cfg EMail $+ %.num
  432.     if (%.num == %email.accnum) set %.cur - %col.dark $+ (current)
  433.     else unset %.cur
  434.     dispr @Info $chr(160) ò %col.target $+ $chr(35) $+ %.num $+  - $_mailcfg(%.cfg,name) - $_mailcfg(%.cfg,user) / $_mailcfg(%.cfg,addr) / $_mailcfg(%.cfg,who) %.cur
  435.     if ($_vi(.num) <= %email.acclast) goto loop
  436.     halt
  437.   }
  438.   if (n isin $1) {
  439.     set %email.accnum $_vi(email.acclast)
  440.     set %email.curr Current- %email.accnum $+ . %email.account
  441.     _esaveacc %email.accnum
  442.     disp New e-mail account created ( $+ %col.target $+ $chr(35) $+ %email.accnum $+ ) Please give it a unique name and settings.
  443.     goto cfg
  444.   }
  445.   if (%email.acclast <= 1) if ((d isin $1) || (r isin $1)) _error You need more than one account defined before you can delete accounts.
  446.   if (d isin $1) set %.todel %email.accnum
  447.   elseif (r isin $1) {
  448.     if (($2 < 1) || ($2 > %email.acclast) || ($2 !isnum)) _error You must give a valid account number to remove.
  449.     set %.todel $2
  450.   }
  451.   else {
  452.     if (($1 < 1) || ($1 > %email.acclast) || ($1 !isnum)) _error You must give a valid account number to switch to.
  453.     _eloadacc $1
  454.     goto cfgp
  455.   }
  456.   if (%.todel != %email.accnum) _eloadacc %.todel
  457.   disp E-Mail account %col.att $+ deleted - %col.target $+ %email.accnum $+  - %email.account
  458.   if (%.todel == %email.acclast) {
  459.     set %.cfg EMail $+ %.todel
  460.     _remmailc %.cfg
  461.     _eloadacc 1
  462.   }
  463.   else {
  464.     _eloadacc %email.acclast
  465.     _remmailc %.cfg
  466.     _esaveacc %.todel
  467.     set %email.accnum %.todel
  468.   }
  469.   set %email.curr Current- %email.accnum $+ . %email.account
  470.   set %email.pu [ $+ [ %email.acclast ] ]
  471.   dec %email.acclast
  472.   :cfgp
  473.   disp E-Mail account loaded - %col.target $+ %email.accnum $+  - %email.account
  474.   :cfg
  475.   if (($_isopen(@Account) == $true) || (n isin $1)) ecfg
  476. }
  477. alias _esaveacc {
  478.   set %.cfg EMail $+ $1
  479.   set %email.pu [ $+ [ $1 ] ] $1. %email.account
  480.   _writemailc %.cfg name %email.account
  481.   _writemailc %.cfg smtp %email.smtp
  482.   _writemailc %.cfg pop3 %email.pop3
  483.   _writemailc %.cfg user %email.user
  484.   _writemailc %.cfg pw %email.pw
  485.   _writemailc %.cfg addr %email.email
  486.   _writemailc %.cfg reply %email.replyto
  487.   _writemailc %.cfg who %email.ffrom
  488.   _writemailc %.cfg org %email.org
  489.   _writemailc %.cfg sig %email.sig
  490.   _writemailc %.cfg cret %email.cret
  491.   _writemailc %.cfg wrap %email.wrap
  492.   _writemailc %.cfg ccsend %email.fastsend
  493.   _writemailc %.cfg auto %email.autocheck
  494. }
  495. alias _eloadacc {
  496.   set %.cfg EMail $+ $1
  497.   set %email.accnum $1
  498.   set %email.account $_mailcfg(%.cfg,name)
  499.   set %email.curr Current- %email.accnum $+ . %email.account
  500.   set %email.smtp $_mailcfg(%.cfg,smtp)
  501.   set %email.pop3 $_mailcfg(%.cfg,pop3)
  502.   set %email.user $_mailcfg(%.cfg,user)
  503.   set %email.pw $_mailcfg(%.cfg,pw)
  504.   set %email.email $_mailcfg(%.cfg,addr)
  505.   set %email.replyto $_mailcfg(%.cfg,reply)
  506.   set %email.ffrom $_mailcfg(%.cfg,who)
  507.   set %email.org $_mailcfg(%.cfg,org)
  508.   set %email.sig $_mailcfg(%.cfg,sig)
  509.   set %email.cret $_mailcfg(%.cfg,cret)
  510.   set %email.wrap $_mailcfg(%.cfg,wrap)
  511.   set %email.fastsend $_mailcfg(%.cfg,ccsend)
  512.   set %email.autocheck $_mailcfg(%.cfg,auto)
  513. }
  514. alias email {
  515.   if ($left($1,2) isin cfcose) ecfg $2-
  516.   elseif ($left($1,2) == ac) eacc $2-
  517.   elseif ($left($1,1) isin snme) esend $2-
  518.   elseif ($left($1,1) isin ab) ebook
  519.   else echeck
  520. }
  521. menu menubar {
  522.   -
  523.   E-Mail
  524.   .Check...:echeck
  525.   .Compose new...:esend
  526.   .Address book...:ebook
  527.   .-
  528.   .Account
  529.   ..%email.curr:eacc %email.accnum
  530.   ..-
  531.   ..%email.pu1:eacc 1
  532.   ..%email.pu2:eacc 2
  533.   ..%email.pu3:eacc 3
  534.   ..%email.pu4:eacc 4
  535.   ..%email.pu5:eacc 5
  536.   ..%email.pu6:eacc 6
  537.   ..%email.pu7:eacc 7
  538.   ..%email.pu8:eacc 8
  539.   ..%email.pu9:eacc 9
  540.   ..-
  541.   ..New account...:eacc n
  542.   ..Delete current
  543.   ...Yes I'm sure:eacc d
  544.   ..Rename current...:set %_arhelp ecfg n | _askr _arhelp New name for account %email.accnum $+ ?
  545.   .Configure...:ecfg
  546.   .Auto check
  547.   ..When
  548.   ...$_dynpop($_if( [ %email.auto.when ] == off)) Disable:set %email.auto.when off | disp E-Mail auto check disabled.
  549.   ...$_dynpop($_if( [ %email.auto.when ] == away)) Only when away:set %email.auto.when away | disp E-Mail auto check will only occur when you are away.
  550.   ...$_dynpop($_if( [ %email.auto.when ] == here)) Only when here:set %email.auto.when here | disp E-Mail auto check will only occur when you are not away.
  551.   ...$_dynpop($_if( [ %email.auto.when ] == on)) Anytime:set %email.auto.when on | disp E-Mail auto check enabled. (will occur whether you are away or not)
  552.   ..Frequency
  553.   ...Currently every %email.auto.freq minutes:disp E-Mail auto check occurs every %email.auto.freq minutes.
  554.   ...-
  555.   ...Every 5 minutes:_acsfreq 5
  556.   ...Every 10 minutes:_acsfreq 10
  557.   ...Every 15 minutes:_acsfreq 15
  558.   ...Every 20 minutes:_acsfreq 20
  559.   ...Every X minutes...:_askr _acsfreq Number of minutes between e-mail checks?
  560.   ..Only if idle
  561.   ...Currently must idle %email.auto.idle %email.auto.idlet:disp E-Mail auto check only occurs if you are idle %email.auto.idle %email.auto.idlet or more.
  562.   ...-
  563.   ...Idle 0 seconds:_acsidle 0 s
  564.   ...Idle 15 seconds:_acsidle 15 s
  565.   ...Idle 30 seconds:_acsidle 30 s
  566.   ...Idle 60 seconds:_acsidle 60 s
  567.   ...Idle 5 minutes:_acsidle 5
  568.   ...Idle 10 minutes:_acsidle 10
  569.   ...Idle X minutes...:_askr _acsidle Number of minutes you must idle before e-mail check will occur?
  570.   ..Account
  571.   ...$_dynpop($_if( [ %email.auto.acc ] == curr)) Current only:set %email.auto.acc curr | disp E-Mail auto check will only check the currently loaded account. (assuming auto check is on for that account)
  572.   ...$_dynpop($_if( [ %email.auto.acc ] == all)) All accounts:set %email.auto.acc all | disp E-Mail auto check will check all accounts that have auto check enabled.
  573.   ...$_dynpop($_if( [ %email.auto.acc ] == cycle)) Current, then load next:set %email.auto.acc cycle | disp E-Mail auto check will check the currently loaded account, then load the next account (in order) that has auto check enabled.
  574.   ..If found
  575.   ...$_dynpop($_if( [ %email.auto.do ] == tb)) Show in titlebar:set %email.auto.do tb | disp If e-mail is detected, a count of new messages will be shown in the mIRC titlebar.
  576.   ...$_dynpop($_if( [ %email.auto.do ] == note)) Display note:set %email.auto.do note | disp If e-mail is detected, a note will be displayed in the active window.
  577.   ...$_dynpop($_if( [ %email.auto.do ] == win)) Popup window:set %email.auto.do win | disp If e-mail is detected, the e-mail window will be displayed.
  578.   ...$_dynpop($_if( [ %email.auto.do ] == get)) Get headers:set %email.auto.do get | disp If e-mail is detected, the e-mail window will be displayed and the e-mail headers will be downloaded.
  579.   ..-
  580.   ..Defaults (on):set %email.auto.when on | set %email.auto.freq 10 | set %email.auto.idle 0 | set %email.auto.acc curr | set %email.auto.do tb | disp Automatic e-mail checks enabled with default behavior.
  581.   .-
  582.   .Get mail
  583.   ..$_dynpop(%email.get.reverse) in reverse order:dispa Mail will be downloaded in "reverse" order, so the OLDEST message will be displayed on top. | set %email.get.reverse $true
  584.   ..$_dynpop($_not(%email.get.reverse)) in normal order:dispa Mail will be downloaded in "normal" order, so the NEWEST message will be displayed on top. | set %email.get.reverse $false
  585.   ..-
  586.   ..$_dynpop($_not(%email.get.min)) normal window:dispa Mail windows will open normally, as they are downloaded | set %email.get.min $false
  587.   ..$_dynpop(%email.get.min) minimized:dispa Mail windows will be minimized as you receive them, for you to restore manually yourself | set %email.get.min $true
  588.   .-
  589.   .Help:help ! e-mail system
  590. }
  591. alias _acsfreq set %email.auto.freq $1 | disp E-Mail auto check will occur every %email.auto.freq minutes. | _acstimer
  592. alias _acsidle set %email.auto.idle $1 | if ($2 == s) set %email.auto.idlet seconds | else set %email.auto.idlet minutes | disp E-Mail auto check will only occur if you are idle %email.auto.idle %email.auto.idlet or more.
  593. on 1:start:_acstimer
  594. alias _acstimer if (%email.auto.freq > 0) .timer915 -o 1 $calc(%email.auto.freq * 60) _acsdo
  595. alias _acstimerq if (%email.auto.freq > 0) .timer915 -o 1 $calc(%email.auto.freq * 20) _acsdo
  596. alias _acsdo {
  597.   if (%email.auto.when == off) { _acstimer | return }
  598.   if ((%email.auto.when == away) && (%_away.why == $null)) { _acstimer | return }
  599.   if ((%email.auto.when == here) && (%_away.why != $null)) { _acstimer | return }
  600.   set %.idle $idle
  601.   if (%email.auto.idlet != seconds) set %.idle $calc(%.idle / 60)
  602.   if (%.idle < %email.auto.idle) { _acstimerq | return }
  603.   set %.wins $window(0)
  604.   if (%.wins > 0) {
  605.     if (($_isopen(@Progress)) || ($_isopen(@Error)) || ($_isopen(@Quick))) { _acstimerq | return }
  606.     :loopw
  607.     set %.winw $window(%.wins)
  608.     if (EMail isin %.winw) { _acstimer | return }
  609.     if ($_vd(.wins) > 0) goto loopw
  610.   }
  611.   unset %-+eacs.halt
  612.   if (%email.auto.acc == curr) {
  613.     if (%email.autocheck !isin onyesenabled$true) { _acstimer | return }
  614.     echeck q
  615.   }
  616.   else {
  617.     if (%email.autocheck !isin onyesenabled$true) {
  618.       set %.load $_acsfind(%email.accnum)
  619.       if (%.load == $null) { _acstimer | return }
  620.       _eloadacc %.load
  621.     }
  622.     set %-eacs.start %email.accnum
  623.     echeck q
  624.   }
  625.   _acstimer
  626. }
  627. alias _acsfind {
  628.   set %.next $_i($1)
  629.   :loop
  630.   if (%.next > %email.acclast) set %.next 1
  631.   if (%.next == %email.accnum) set %.isac %email.autocheck
  632.   else { set %.nini EMail $+ %.next | set %.isac $_mailcfg(%.nini,auto) }
  633.   if (%.isac isin onyesenabled$true) return %.next
  634.   if (%.next == $1) return $null
  635.   inc %.next
  636.   goto loop
  637. }
  638. alias _eac.fin {
  639.   if ($2 > 0) {
  640.     if (%email.auto.do == tb) { .enable #_email-tb | set %_email-tb - E-Mail: $2 on %email.account }
  641.     elseif (%email.auto.do == note) dispa New e-mail detected- %col.target $+ $2 messages. ( $+ $3 bytes) (account %email.accnum $+ - %email.account $+ )
  642.     elseif (%email.auto.do == win) {
  643.       window -c @EMail
  644.       window -l @EMail $_winpos(14%,7%,8%,8%) @EMail %font.basic
  645.       titlebar @EMail check
  646.       aline @EMail $chr(160)
  647.       aline @EMail New e-mail detected- (account %email.accnum $+ - %email.account $+ )
  648.       aline @EMail $chr(160)
  649.       aline @EMail --> %col.att $+ $2 <-- e-mail messages waiting ( $+ %col.dark $+ $3 bytes)
  650.       aline @EMail $chr(160)
  651.       aline @EMail Right-click on this window for options, press F4 to get message headers.
  652.       window -b @EMail
  653.       .enable #_epopup1
  654.     }
  655.     else _echeader
  656.   }
  657.   else {
  658.     .disable #_email-tb
  659.     if (%email.auto.acc != curr) {
  660.       if (%-+eacs.halt) { unset %-+eacs.halt %-eacs.start | return }
  661.       return
  662.       set %.load $_acsfind(%email.accnum)
  663.       if ((%.load == $null) || (%.load == %email.accnum)) return
  664.       _eloadacc %.load
  665.       if (%email.auto.acc == all) {
  666.         if (%-eacs.start != %email.accnum) { echeck q | return }
  667.       }
  668.       unset %-eacs.start
  669.     }
  670.   }
  671. }
  672. on 1:load:{
  673.   set %.ini $_ppdir $+ email.ini
  674.   if ($exists(%.ini)) {
  675.     set %email.get.reverse $_mailcfg(Settings,Get)
  676.     set %email.auto.when $_mailcfg(Settings,When)
  677.     set %email.auto.freq $_mailcfg(Settings,Freq)
  678.     set %email.auto.idle $_mailcfg(Settings,Idle)
  679.     set %email.auto.idlet $_mailcfg(Settings,IT)
  680.     set %email.auto.acc $_mailcfg(Settings,Acc)
  681.     set %email.auto.do $_mailcfg(Settings,Do)
  682.     set %email.acclast $_mailcfg(Settings,A)
  683.     set %email.book Book1
  684.     set %.nuku %email.acclast
  685.     :loop
  686.     _eloadacc %.nuku
  687.     _esaveacc %.nuku
  688.     if ($_vd(.nuku) > 0) goto loop
  689.   }
  690.   else {
  691.     set %email.get.reverse $true
  692.     set %email.auto.when off
  693.     set %email.auto.freq 15
  694.     set %email.auto.idle 5
  695.     set %email.auto.idlet minutes
  696.     set %email.auto.acc curr
  697.     set %email.auto.do note
  698.     set %email.acclast 1
  699.     set %email.account Default
  700.     set %email.accnum 1
  701.     set %email.email $email
  702.     set %email.wrap 78
  703.     set %email.curr Current- 1. Default
  704.     set %email.pu1 1. Default
  705.     set %email.book Book1
  706.     set %email.fastsend on
  707.     set %email.autocheck on
  708.     unset %email.smtp %email.pop3 %email.user %email.sig %email.ffrom %email.org %email.replyto %email.pw %email.cret
  709.     _esaveacc 1 | _writemailc Settings Books 1
  710.     _writemailc Book1 Name Default Book
  711.     _writemailc Book1 1 misspai <michiru@earthlink.net>
  712.   }
  713. }
  714. alias _emunload {
  715.   .timer915 off
  716.   window -c @EMail | window -c @Address | window -c @Account
  717.   _esaveacc %email.accnum
  718.   _writemailc Settings Get %email.get.reverse
  719.   _writemailc Settings When %email.auto.when
  720.   _writemailc Settings Freq %email.auto.freq
  721.   _writemailc Settings Idle %email.auto.idle
  722.   _writemailc Settings IT %email.auto.idlet
  723.   _writemailc Settings Acc %email.auto.acc
  724.   _writemailc Settings Do %email.auto.do
  725.   _writemailc Settings A %email.acclast
  726. }
  727. alias _cloem set %.loop $window(0) | :loop | if (@EMail?* iswm $window(%.loop)) window -c $window(%.loop) | if ($_vd(.loop) > 0) goto loop
  728.